// 待办中心接口
import {request} from "@utils/request";
import {
  getCurrentOrganizationId
} from '@/utils/util.js'
// 当前租户ID
// const organizationId = getCurrentOrganizationId();
const api = {
  getWorkItemAttrs: "/workflow/Windchill/servlet/rest/hzero/foundation/workflow/getWorkItemAttrs",
  getWorkItemList: "/workflow/Windchill/servlet/rest/hzero/foundation/workflow/getWorkItemList",
  getProjectTaskAttrs: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/getProjectTaskAttrs",
  getProjectTaskList: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/getProjectTaskList",
  getProjectTaskAttrsForApproval: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/getProjectTaskAttrsForApproval",
  getProjectTaskListForApproval: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/getProjectTaskListForApproval",
  getAttributeGroup: "/project/Windchill/servlet/rest/hzero/pdm/attribute/getAttributeGroup",
  getDeliverableAttrs: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/getDeliverableAttrs",
  getDeliverableList: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/getDeliverableList",
  getLastResourceHour: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/getLastResourceHour",
  sumResource: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/sumResource",
  verifyActivity: "/deliver/Windchill/servlet/rest/hzero/pmgt/task/verifyActivity",
  updateDeliverabeSubject: "/deliver/Windchill/servlet/rest/hzero/pmgt/deliverable/updateDeliverabeSubject",
}
// let auth = {
//   username: "wcadmin",
//   password: "wcadmin"
// };
// 获取流程任务表头
export function getWorkItemAttrs(parameter) {
  return request({
    url: api.getWorkItemAttrs,
    method: "post",
    data: parameter,
  });
}
//获取流程任务表格数据
export function getWorkItemList(parameter) {
  return request({
    url: api.getWorkItemList,
    method: "post",
    data: parameter,
  });
}
// 获取执行任务表头
export function getProjectTaskAttrs(parameter) {
  return request({
    headers: {'Content-Type': 'application/json;charset=utf-8'},
    url: api.getProjectTaskAttrs,
    method: "post",
    data: parameter,
  });
}
//获取执行任务表格数据
export function getProjectTaskList(parameter) {
  return request({
    url: api.getProjectTaskList,
    method: "post",
    data: parameter,
  });
}
// 需求管理接口
export function demandManage(parameter) {
  // parameter.userName = 'yufx'
  return request({
    url: `/portal/v1/${getCurrentOrganizationId()}/resarch-portal/query-todo`,
    method: 'post',
    data: parameter,
  })
}
// 获取审核任务表头
export function getProjectTaskAttrsForApproval(parameter) {
  return request({
    url: api.getProjectTaskAttrsForApproval,
    method: "post",
    data: parameter,
  });
}
//获取审核任务表格数据
export function getProjectTaskListForApproval(parameter) {
  return request({
    url: api.getProjectTaskListForApproval,
    method: "post",
    data: parameter,
  });
}
//执行任务--基本属性（对象布局与属性）
export function getAttributeGroup(parameter) {
  return request({
    url: api.getAttributeGroup,
    method: "post",
    data: parameter,
  });
}
//执行任务--获取交付物表头
export function getDeliverableAttrs(parameter) {
  return request({
    url: api.getDeliverableAttrs,
    method: "post",
    data: parameter,
  });
}
//执行任务--获取交付物列表
export function getDeliverableList(parameter) {
  return request({
    url: api.getDeliverableList,
    method: "post",
    data: parameter,
  });
}
//执行任务--申请完成--获取上一次汇报的工时记录
export function getLastResourceHour(parameter) {
  return request({
    url: api.getLastResourceHour,
    method: "post",
    data: parameter,
  });
}
//执行任务--申请完成
export function sumResource(parameter) {
  return request({
    url: api.sumResource,
    method: "post",
    data: parameter,
  });
}
//审核任务--流程处理
export function verifyActivity(parameter) {
  return request({
    url: api.verifyActivity,
    method: "post",
    data: parameter,
  });
}
//添加交付物
export function updateDeliverabeSubject(parameter = {}) {
  return request({
    url: api.updateDeliverabeSubject,
    method: 'post',
    data: parameter,
  })
}